package com.kfm.pm;

import java.nio.charset.Charset;
import java.util.Arrays;

public class StringExample03 {

    public static void main(String[] args) {
        String str = "kaifamiao";
        byte[] bytes = str.getBytes();
        System.out.println(Arrays.toString(bytes));
        System.out.println(Charset.defaultCharset());
        Charset gbk = Charset.forName("GBK");
        byte[] bytes1 = "原神".getBytes(gbk);
        System.out.println(Arrays.toString(bytes1));
        System.out.println(new String(bytes1, gbk));

        String str1 = new String(bytes, 0, bytes.length);
        System.out.println(str1);
    }
}
